package com.example.basicframework

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.example.basicframework.config.kotlin.g
import com.example.basicframework.config.kotlin.tool
import com.example.basicframework.config.kotlin.viewBinding
import com.example.basicframework.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {
    private val vb by viewBinding(ActivityMainBinding::inflate)
    val TAG = "MainActivity"
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(vb.root)
        tool.apply {
            if (get("server").isEmpty() || get("port").isEmpty()) {
                set("server","124.93.196.45")
                set("port","10001")
            }
        }
        tool.apply {
            send("/prod-api/api/rotation/list","get",null,true) {
                val data = g.fromJson(it,BannerBean::class.java).rows
                val list = mutableListOf<String>()
                for (i in data.indices) {
                    list.add(data[i].advImg)
                }
                setBanner(vb.banner, list)
            }
        }
    }
}